<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>元素的大小和位置系列</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    #box{
      margin-left: 100px;
      width: 500px;
      height: 500px;
      border: 10px solid blue;
      background-color: red;
    }
    #box #box1 {
      width: 300px;
      height: 300px;
      padding: 10px;
      border: 10px solid deepskyblue;
      background-color: green;
    }
    #box #box1 #box2{
      width: 500px;
      height: 500px;
      border: 13px solid purple;
      background-color: yellow;
    }
  </style>
</head>
<body>
  <div id="box">
    <div id="box1">
      <div id="box2"></div>
    </div>
  </div>

  <script>
    //js操作的是行内元素,通过css设置的宽度获取不到
    var box = document.getElementById("box");
    var box1 = document.getElementById("box1");
    // console.log(box1.style.width);
    console.log("box1的offsetWidth: ",box1.offsetWidth);
    console.log("box1的clientWidth: ",box1.clientWidth);
    console.log("box1的scrollWidth: ",box1.scrollWidth);
  </script>
</body>
</html>